      subroutine idxpqr_s(ioff, numi, popp, popq, ioppq, popr, pops, & 
                         ioprs, sym) 
      use mod_iop
      use mod_symm
      use mod_orbit 
      implicit none 
!
      integer, intent(in) :: numi
      integer, intent(out) :: ioff(numi, 8)
      integer, intent(in) :: popp(8), popq(8), popr(8), pops(8)  
      integer, intent(in) :: ioppq, sym, ioprs
!
      integer irrepp, irrepq, irrepr, irreps,irreppqr, iofft
      integer nump, numq, numr, nums, numpq 
      integer p, q, r, s
!      
      integer, external :: irpdso, idsymsoc, isymoffso
      double precision, external :: dnrm2
!
      iofft = 1  
      do irreps = 1, nirrep 
         irreppqr = dirprd(irreps, sym)
         nums = pops(irreps) 
         do s = 1, nums
            ioff(s, irreps) = iofft
            iofft = iofft +  &
                 idsymsoc(irreppqr, popp, popq, ioppq, popr, zorb, 1)
         enddo
      enddo
!
      return
      end
!
      subroutine idxpq_rs(ioff, nummaxr, nummaxs, popp, popq, ioppq, &
                        popr, pops, ioprs, sym)
      use mod_symm 
      implicit none
!
      integer, intent(in) :: nummaxr, nummaxs
      integer, intent(out) :: ioff(nummaxr, nummaxs, 8, 8)
      integer, intent(in) :: popp(8), popq(8), popr(8), pops(8)
      integer, intent(in) :: ioppq, ioprs, sym
!
      integer irrepp, irrepq, irrepr, irreps,irreppqr, iofft
      integer irreprs, irreppq
      integer nump, numq, numr, nums, numpq, numrs, istartrs
      integer p, q, r, s
!      
      integer, external :: irpdso, idsymsoc, isymoffso
      double precision, external :: dnrm2
      istartrs = 0
      do irreprs = 1, nirrep 
         irreppq = dirprd(irreprs, sym) 
         numpq = irpdso(irreppq, popp, popq, ioppq)
         numrs = irpdso(irreprs, popr, pops, ioprs) 
         do irreps = 1, nirrep 
            irrepr = dirprd(irreps, irreprs) 
            numr = popr(irrepr)
            nums = pops(irreps) 
            do s = 1, nums 
            do r = 1, numr
               iofft = istartrs + & 
                      (isymoffso(irreps, irreprs, popr, pops,ioprs) -1 + &
                      (s-1)*numr + r - 1)*numpq + 1
               ioff(r,s,irrepr,irreps) = iofft
            enddo 
            enddo
          enddo
          istartrs = istartrs + numpq*numrs
       enddo
!
      return
      end











      
